package com.itheima.blog.util;

import java.time.*;
import java.time.format.*;

/**
 * @author lijing
 * @date 2019-10-12 14:40
 * @description 整个项目的全局工具类
 */
public class BlogUtils {
    /**
     * java8格式化日期
     *
     * @param millis
     * @param pattern
     * @return
     */
    public static String formatDate(Long millis, String pattern) {
        Instant instant = Instant.ofEpochMilli(millis);
        LocalDateTime localDateTime = LocalDateTime.ofInstant(instant, ZoneId.systemDefault());
        String format = localDateTime.format(DateTimeFormatter.ofPattern(pattern));
        return format;
    }
}
